package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import service.ValidateCodeService;

/**
 * 套餐管理
 */
@RestController
@RequestMapping("/validateCode")
public class ValidateCodeControllor {

    @Reference
    private ValidateCodeService validateCodeService;

    /**
     * 套餐预约发送验证码
     * @param
     * @return
     */
    @RequestMapping("/send4Order")
    public Result send4Order(String telephone){
        try {
            validateCodeService.send4Order(telephone);
            return new Result(true, MessageConstant.SEND_VALIDATECODE_SUCCESS);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.SEND_VALIDATECODE_FAIL);
        }
    }
    /**
     * 用于手机快速登录
     * 短信登录发送验证码
     * @param
     * @return
     */
    @RequestMapping("/send4Login")
    public Result send4Login(String telephone){
        try {
            validateCodeService.send4Login(telephone);
            return new Result(true, MessageConstant.SEND_VALIDATECODE_SUCCESS);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.SEND_VALIDATECODE_FAIL);
        }
    }






}
